package com.hlxt.nj.busi.service.impl;

import com.hlxt.nj.busi.dao.TCourseDAO;
import com.hlxt.nj.busi.model.TCourse;
import com.hlxt.nj.busi.model.TCourseCriteria;
import com.hlxt.nj.busi.service.CourseService;
import com.hlxt.nj.common.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private TCourseDAO courseDAO;

    @Override
    public void selectPageBeanByExample(TCourseCriteria example, PageBean pageBean) {

        courseDAO.selectPageBeanByExample(example,pageBean);
    }

    @Override
    public boolean insert(TCourse course) {
        try{
           courseDAO.insertSelective(course);
            return true;
        }catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public List<TCourse> selectByExample(TCourseCriteria example) {
        return courseDAO.selectByExample(example);
    }

    @Override
    public boolean updateByPrimaryKey(TCourse record) {
        try{
            courseDAO.updateByPrimaryKeySelective(record);
            return true;
        }catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public TCourse selectByPrimaryKey(String id) {
        return courseDAO.selectByPrimaryKey(id);
    }

    @Override
    public boolean deleteByPrimaryKey(String id) {
        try{
            courseDAO.deleteByPrimaryKey(id);
            return true;
        }catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
